/**
 * Created by wzj on 2017/5/17.
 */
/**
 *
 * 框架类
 * Created by WangZhenJia on 2017/5/17.
 */
var jbsframe;
$(document).ready(function(){
	jbsframe = new JBSFrame();

	//时间控件
	jbsframe.renderDatetimepicker();
});

function JBSFrame() {
	var self = this;

	//系统alert提示

	self.alert = function(msg){
		$.growl({ message: msg,location:"tc",size:"large", delayOnHover:false,fixed:false});
	}


	//所有含有datetimepicker元素生成时间控件
	self.renderDatetimepicker =  function() {
		$(".datetimepicker").each(function (index, element) {
			$(element).datetimepicker({
				locale: 'zh-cn',
				format: 'YYYY-MM-DD HH:mm:ss',//日期的格式
				showClose: true,
				showClear:true,
				icons: {
					time: 'fa fa-clock-o',
					date: 'fa fa-calendar',
					up: 'fa fa-chevron-up',
					down: 'fa fa-chevron-down',
					previous: 'fa fa-chevron-left',
					next: 'fa fa-chevron-right',
					today: 'glyphicon glyphicon-screenshot',
					clear: 'fa fa-trash',
					close: 'fa fa-remove'
				},
				tooltips: {
					today: '今天',
					clear: '清除选择',
					close: '关闭',
					selectMonth: '选择月份',
					prevMonth: '上个月',
					nextMonth: '下个月',
					selectYear: '选择年份',
					prevYear: '上一年',
					nextYear: '下一年',
					selectDecade: 'Select Decade',
					prevDecade: 'Previous Decade',
					nextDecade: 'Next Decade',
					prevCentury: 'Previous Century',
					nextCentury: 'Next Century',
					pickHour: '选择小时',
					incrementHour: '增加一小时',
					decrementHour: '减少一小时',
					pickMinute: '选择分钟',
					incrementMinute: '增加一分钟',
					decrementMinute: '减少一分钟',
					pickSecond: '选择秒',
					incrementSecond: '增加一秒',
					decrementSecond: '减少一秒',
					togglePeriod: 'Toggle Period',
					selectTime: '选择时间'
				}
			});
		});
	}

	//格式化日期
	this.formatDate = function(timestamp){
		return new Date(Number(timestamp)).pattern("yyyy-MM-dd");
	}

	//格式化时间
	this.formatDateTime = function(timestamp){
		return new Date(Number(timestamp)).pattern("yyyy-MM-dd HH:mm:ss");
	}
}

/*-------------------------------------


------------------------------------ */
Growl.prototype.content = function() {
	return "<div class='" + this.settings.namespace + "-close'>" + this.settings.close + "</div>\n<div class='" + this.settings.namespace + "-message'><span class='fa fa-info-circle'></span>" + this.settings.message + "</div>";
};
function alert(message){
	jbsframe.alert(message);
}